import java.util.LinkedList;

class Solution {
    public String findLongestWord(String s,List<String> dictionary) {
        String ret="";
        for(String t:dictionary) {
            for(int i=0,n=0;i<t.length() && n<s.length();n++) {
                if(t.charAt(i)==s.charAt(n)) {
                    i++;
                }
                if(i==t.length()) {
                    if((t.length()>ret.length() )||( t.length()==ret.length() && t.compareTo(s)<0)) {
                        ret=t;
                    }
                }
            }
        }
        return ret;;
    }
}

class Solution1 {
    public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        int ret[]=new int[nums1.length+nums2.length];
        if(ret.length==0) {
            return 0;
        }
        int p1=0,p2=0;
        int dex=0;
        for(;p1< nums1.length && p2< nums2.length;) {
            if(nums1[p1]>nums2[p2]) {
                ret[dex++]=nums2[p2++];
            } else if(nums1[p1]<nums2[p2]) {
                ret[dex++]=nums1[p1++];
            } else if(nums1[p1]==nums2[p2]) {
                ret[dex++]=nums1[p1++];
                ret[dex++]=nums2[p2++];
            }
        }
        if(p1!=nums1.length || p2!= nums2.length) {
            if(p1!=nums1.length) {
                ret[dex++]=nums1[p1++];
            } else {
                ret[dex++]=nums2[p2++];
            }
        }
        if(ret.length%2==0) {
            return ret[ret.length/2];
        } else {
            return (ret[ret.length/2]+ret[ret.length/2+1])/2;
        }
    }
}
public class TestDemo {
    public static void main(String[] args) {
        System.out.println("hello world");

    }
}
